

import java.util.ArrayList;
import java.util.Scanner;

/**
 *
 * @author Admin
 */
public class View {
    Scanner input;
    Student db;
    
    public View() {
        input = new Scanner(System.in);
    }
    
    public int menu() {
        System.out.println("-----MENU----");
        System.out.println("1.Show all");
        System.out.println("2.Add");
        System.out.println("3.Exit");
        System.out.print("Choice: ");

        int choice = check(1, 3);
        
        return choice;
    }
    
    public void display() {
        System.out.println("-----DISPLAY----");
        ArrayList<Student> list = new ArrayList<>();
        db.getAllStudent();
    }
    
    public void add() {
        System.out.println("-----ADD----");
        System.out.print("Name: ");
        String name = input.nextLine();
        
        System.out.print("Discription: ");
        String description = input.nextLine();
        
        Student s = new Student(name, description);
        
    }
    
    public int check(int min, int max) {
       int number;

       while (true) {
           try {
               number = Integer.parseInt(input.nextLine());
           } catch (Exception e) {
               System.out.println("Input a number. Try again");
               continue;
           }
           if (number >= min && number <= max) {
               return number;
           } else {
               System.out.println("Try again from " + min + " to " + max);
               continue;
           }
       }
   }
}